import { createRouter, createWebHistory } from 'vue-router';
import error from '@views/error/error.vue';
import index from '@views/index/index.vue';

const router = createRouter({
	history: createWebHistory(import.meta.env.VITE_BASE_URL),
	routes: [
		{
			path: '/',
			name: 'home',
			redirect: () => ({ path: '/index' })
		},
		// 首页
		{
			path: '/index',
			name: 'index',
			meta: {
				title: '活动列表'
			},
			component: index
		},
		{
			path: '/works',
			name: 'works',
			meta: {
				title: '作品'
			},
			component: () => import('@/views/works/index.vue')
		},
		{
			path: '/works-details',
			name: 'works-details',
			meta: {
				title: '作品'
			},
			component: () => import('@/views/works-details/index.vue')
		},
		{
			path: '/user',
			name: 'user',
			meta: {
				title: '个人中心'
			},
			component: () => import('@/views/user/index.vue')
		},
		{
			path: '/add',
			name: 'add',
			meta: {
				title: '上传'
			},
			component: () => import('@/views/add/index.vue')
		},
		// 捕获所有路由或 404 Not found 路由
		{ path: '/:pathMatch(.*)*', name: 'error', component: error }
	]
});

export default router;
